﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<TestWeb.Models.ViewModel>" %>

<% using (Html.BeginForm("UpdateLoaiTinTuc", "Admin", FormMethod.Post, new { id = "MySubmitForm" }))
	{ %>
	<!-- start table-content  -->
	<div id="table-content">
		<!--  start message-red -->
		<div id="message-red">
			<table border="0" width="100%" cellpadding="0" cellspacing="0">
				<tr>
					<td class="red-left">Error message</td>
				</tr>
			</table>
		</div>
		<!--  end message-red -->
				
		<!-- start product-table -->
		<table border="0" width="100%" cellpadding="0" cellspacing="0" id="product-table">
			<tr>
                <th class="table-header-check line-left">
					<a href="">ID</a>
				</th>
				<th class="table-header-repeat line-left">
					<a href="">TenLoaiTinTuc</a>
				</th>
				<th class="table-header-options line-left">
					<a href="#">Option</a>
				</th>
			</tr>
		<% for (int i = 0; i < Model.LoaiTinTucs.Count; i++)
		{
			var item = Model.LoaiTinTucs[i]; %>
			<% if (i % 2 == 0)
			{ %>
			<tr id="row-<%= item.ID %>" class="row-table odd-row">
			<% }
			else
			{ %>
			<tr id="row-<%= item.ID %>" class="row-table even-row">
			<% } %>
			<% if (Model.LoaiTinTucs[i].ID == (int)ViewData["EditItem"])
			{ %>
                <td>
					<%= item.ID %>
				</td>
				<td>
					<%= Html.TextBox("TenLoaiTinTuc", item.TenLoaiTinTuc, new { @Style = "width: 95%; height: 20px; padding: 0 5px 0 5px;"})%>
				</td>
				<td class="options-width">
                    <input type="hidden" name="ID" value="<%= item.ID %>" />
                    <input type="hidden" name="CurrentPage" value="<%= (int)ViewData["CurrentPage"] %>" />
					<a href="#"  title="Update" class="icon-6 info-tooltip" onclick="submitFormLoaiTinTuc();"></a>
					<%= Ajax.ActionLink(" ", "CancelEditingLoaiTinTuc", "Admin", new { CurrentPage = (int)ViewData["CurrentPage"] }, new AjaxOptions { UpdateTargetId = "PartialDiv" }, new { @class = "icon-7 info-tooltip", @title = "Cancel" })%>
					<%= Html.ActionLink(" ", "DeleteLoaiTinTucWithoutAjax", "Admin", new { ID = item.ID, CurrentPage = (int)ViewData["CurrentPage"] }, new { @class = "icon-2 info-tooltip", @title = "Delete" })%>
				</td>
		<%  }
			else
			{ %>
                <td>
					<%= item.ID %>
				</td>
				<td>
					<%= item.TenLoaiTinTuc%>
				</td>
				<td class="options-width">
					<%= Ajax.ActionLink(" ", "EditLoaiTinTuc", new { ID = item.ID, CurrentPage = (int)ViewData["CurrentPage"] }, new AjaxOptions { UpdateTargetId = "PartialDiv" }, new { @class = "icon-1 info-tooltip", @title = "Edit" })%>
					<%= Html.ActionLink(" ", "DeleteLoaiTinTucWithoutAjax", new { ID = item.ID, CurrentPage = (int)ViewData["CurrentPage"] }, new { @class = "icon-2 info-tooltip", @title = "Delete" })%>
				</td>
			<% } %>
			</tr>
	<% } %>
		</table>
		<!-- end product-table --> 
		<!-- start paging -->
		<div id="pagination">
		<% 
			var nextPage = (int)ViewData["CurrentPage"] + 1;
			var totalPage = (int)ViewData["TotalPage"];
			if (nextPage <= totalPage)
			{ %>
		<%= Html.ActionLink(" ", "SelectLoaiTinTuc", new { Page = nextPage })%>
			<% } %>
		</div>
		<!-- end paging -->
	</div>
	<!-- end content-table  -->
<% } %>